﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${base}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>首页</title>
<script src="${ctx}/js/jquery-1.9.1.min.js"></script>
</head>
<body>


<br />
手机：
<input type="text" id="mobile"
	style="height: 50px; width:300px; font-size: 36px; line-height: 36px" />
<br /><br />
内容：
<textarea rows="8" cols="80" id="msg"></textarea>
<br />
<p align="center">
<input type="button" value="发送" class="myButton" onclick="doPush()" style="height: 50px; width:500px; font-size: 36px; line-height: 36px"/>
</p>

<script>
	function doPush() {
		var mobile = $("#mobile").val();
		if (mobile == "" || mobile.length != 11) {
			alert("请输入手机号，11位。");
			$("#mobile").focus();
			return false;
		}

		var msg = $("#msg").val();
		if (msg == "") {
			alert("请输入内容。");
			$("#msg").focus();
			return false;
		}
		var server=location.href;
		var str="${ctx}";
		var index=server.indexOf(str);
		var newStr=server.substring(0, index);
		//检查手机号
		var url =newStr+"/systemConfig/checkMobile";
		$.post(url, {
			"mobile" : mobile,
		}, function(data) {
			if(data.result=="OK"){
				
				//发送
				var url = newStr+"/systemConfig/pushMsgToOne";
				$.post(url, {
					"passKey" : "1X2B3C4D5X6Y7Z8D9W",
					"mobile" : mobile,
					"msg" : msg
				}, function(data) {
					alert(data.message);
					var url2 = newStr+"${ctx}/companyAdmin/sendMSG";
					$.post(url2, {
						"mobile" : mobile,
						"msg" : msg
					});
				}, 'json');
			
			}else{
				//手机号不存在
				alert(data.message);
			}
		}, 'json');
		

	}
</script>
</body>
</html>